/**
 * 
 */
package edu.rit.cs.web.pages;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.spring.injection.annot.SpringBean;

import edu.rit.cs.core.pojos.AUser;
import edu.rit.cs.core.services.daos.CustomerDAO;
import edu.rit.cs.web.panels.LoginPanel;
import edu.rit.cs.web.panels.QueryPanel;

/**
 * This page allows the customer to query a selected web service. The customer
 * must login before accessing this option. On page load (before the login) this
 * page will try to fetch the list of available business services. 
 * 
 * @see LoginPanel
 * @see QueryPanel
 * 
 * @author Abhishek Shrestha (axs1430)
 * @author Juan Saldana (jjs6109)
 * @author Victor Alvarez (vxa1557)
 */
public class CustomerPage extends WebPage {

  @SpringBean
  private CustomerDAO cd;

  public CustomerPage() throws Exception {
    final QueryPanel queryPanel = new QueryPanel("queryPanel");
    queryPanel.setVisible(false);

    add(new LoginPanel("loginPanel"){
      private static final long serialVersionUID = 1L;

      @Override
      protected AUser getUserByName(String username) {
        return cd.findByUsername(username);
      }

      @Override
      protected void hide() {
        setVisible(false);
        queryPanel.setVisible(true);
      }
    });

    add(queryPanel);
  }
}
